<?php $__env->startSection("content"); ?>
    <body>

    <div class="layuimini-main">

        <div class="layui-form layuimini-form">
            <?php echo e(csrf_field()); ?>


            <div class="layui-form-item">
                <label class="layui-form-label required">优惠券名称</label>
                <div class="layui-input-block">
                    <input type="text" name="coupon_name" lay-verify="required" lay-reqtext="优惠券名称不能为空" placeholder="请输入优惠券名称" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">优惠券价格</label>
                <div class="layui-input-block">
                    <input type="text" name="coupon_fee" lay-verify="required" lay-reqtext="优惠券价格" placeholder="优惠券价格" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">优惠券满减价格</label>
                <div class="layui-input-block">
                    <input type="number" name="total_fee" lay-verify="required" lay-reqtext="优惠券满减价格" placeholder="请输入优惠券满减价格" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">日期时间范围</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="from_to_date" id="from_to_date" placeholder="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">是否上架</label>
                <div class="layui-input-block">
                    <input type="checkbox" checked="" name="is_on" lay-skin="switch" lay-filter="switchTest" lay-text="ON1|OFF">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
    <script src="<?php echo e(asset("admin")); ?>/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>


    <script>

        layui.use(['form', 'table','laydate'], function () {
            var form = layui.form,
                layer = layui.layer,
                table = layui.table,
                $ = layui.$;
            var laydate = layui.laydate;

            /**
             * 初始化表单，要加上，不然刷新部分组件可能会不加载
             */
            form.render();

            //日期时间范围
            laydate.render({
                elem: '#from_to_date'
                ,type: 'datetime'
                ,range: true
            });



            // 当前弹出层，防止ID被覆盖
            var parentIndex = layer.index;

            //监听提交
            form.on('submit(saveBtn)', function (data) {
                $.post("/admin/coupon",data.field,function (res) {
                    if(res.status==200){
                        layer.msg(res.msg,function () {
                            var index = parent.layer.getFrameIndex(window.name); // 获取当前窗口的索引
                            parent.layer.close(index); // 关闭当前窗口
                            parent.location.reload();
                        });
                    }else {
                        layer.msg(res.msg);
                    }
                });
                return false;
            });

        });
    </script>
    </body>
<?php $__env->stopSection(); ?>

<?php echo $__env->make("layout.base", \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Users/jdl/Desktop/黑马/laravelApi/resources/views/admin/coupon/add.blade.php ENDPATH**/ ?>